// messageboxutil.h

#ifndef MESSAGEBOXUTIL_H
#define MESSAGEBOXUTIL_H

#include <QMessageBox>
#include <QObject>

class MessageBoxUtil : public QObject
{
    Q_OBJECT
public:
    explicit MessageBoxUtil(QObject *parent = nullptr);

    // 定义消息框类型的枚举
    enum MessageBoxType {
        Question,
        Information,
        Warning,
        Critical
    };

    // 定义按钮类型的枚举（使用2的幂值以支持按位或）
    enum ButtonType {
        NoButton = 0x00000000,
        Ok       = 0x00000400,  // 使用与 QMessageBox::StandardButton 相同的值
        Cancel   = 0x00400000,
        Yes      = 0x00004000,
        No       = 0x00010000,
        Abort    = 0x00040000,
        Retry    = 0x00200000,
        Ignore   = 0x00100000
    };
    Q_DECLARE_FLAGS(ButtonTypes, ButtonType)

    // 静态函数用于显示消息框
//    static int showMessage(QWidget *parent, MessageBoxType type, const QString &title, const QString &text,
//                           ButtonTypes buttons = Ok);
    static int showMessage(QWidget *parent, MessageBoxType type, const QString &title, const QString &text);

    static int hintMessage(QWidget *parent, MessageBoxUtil::MessageBoxType type, const QString &title, const QString &text);
private:
    static QMessageBox::StandardButton convertToStandardButton(ButtonType button);
    static QString getButtonText(ButtonType button);
};

Q_DECLARE_OPERATORS_FOR_FLAGS(MessageBoxUtil::ButtonTypes)

#endif // MESSAGEBOXUTIL_H
